<?php  
import('miho.db.entity.fields.BaseEntityField');

class BaseEntity{
    
  protected $_fields;
  protected $_primaryField;
  public function __constuct(){
    $_fields = array();
    $this->_initialize();
  }
  
  protected function _initialize(){
    
  }
  
  public function mapPrimary($name, BaseTableField $field){
    $this->_primaryField = $field;
  }
  
  public function mapField($name, BaseTableFild $field,$criteria=null){
    if($criteria==null){
      $criteria = new Criteria();
      if($field->getTable()!=$this->_primaryField->getTable()){
        $table=getTable();
        $criteria->add($this->_primaryField,$table[$this->_primaryField->getName()],Criteria::EQUAL);
      }
    }
    $this->_fields[$name] = array(
        'field' => $field,
        'criteria'=>$criteria
      );
  }
  
  public function save(){
    
  }
  
  public function delete(){
    
  }
  
  public function isValid(){
    return true;
  }
}

?>